﻿using System;
using HsTec.Mobile.Green.BLL;

public partial class PowerWarning_ProvinceForecastManage : Baimasoft.Web.UI.PageManagerTop
{
    ProvinceForecastBLL bll = new ProvinceForecastBLL();

    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            Indicator.Text = Request.QueryString["sIndicator"].ToString();
        }
        catch
        {
        }

        this.BindControlEvent();

        this.HiddenID.Value = "";
        if (!this.IsPostBack)
        {
            this.BindGridViewData();
        }
    }

    protected override void BindGridViewData()
    {
        this.DataSource = bll.GetList(GetSearchString()).Table;
        this.DataSource.DefaultView.Sort = this.SortString;
        GridView1.DataSource = this.DataSource.DefaultView;
        GridView1.DataBind();
    }


    protected override void Delete(string ids)
    {
        try
        {
            int iback = bll.Delete(ids);
            if (iback < 1)
            {
                Baimasoft.Web.UI.Message.AlertMsg(this, "没有可删除的数据");
                return;
            }
            else
            {
                Baimasoft.Web.UI.Message.AlertMsg(this, "删除成功");
                return;
            }
        }
        catch
        {
            Baimasoft.Web.UI.Message.AlertMsg(this, "删除失败");
            return;
        }
    }

    protected override string GetSearchString()
    {
        string searchStr = string.Empty;
        searchStr += " (1=1) ";
        if (sltMonth.Value == "")
        {
            searchStr += " and  substring(Years,1,4) ='" + sltYear.Value + "' ";
        }
        else
        {
            searchStr += " and  Years ='" + sltYear.Value + sltMonth.Value + "' ";
        }
        return searchStr;
    }

    protected void btnRefresh_Click(object sender, EventArgs e)
    {
        this.DataSource = bll.GetList(GetSearchString()).Table;
        this.DataSource.DefaultView.Sort = this.SortString;
        GridView1.DataSource = this.DataSource.DefaultView;
        GridView1.DataBind();
    }
}
